<?php
$this->renderPartial('application.modules.member.views.main.info');
?>
<br />
<h2>Log Ewallet</h2>
<div class="add">
    <form action="" method="post" name="member_form">
        <table cellpadding="0" cellspacing="0">
            <tr class="title">
                <th colspan="5" style="text-align:left;"><strong>&nbsp;</strong></th>
            </tr>
            <tr>
                <th width="80">Lihat data</th>
                <td width="100" class="no-border">
                    <?php
                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'value'=>$date_start,
                        'name' => 'date_start',
                        'options' => array(
                            'showAnim' => 'fold',
                            'dateFormat' => 'yy-mm-dd', // save to db format
                            'altField' => '#self_pointing_id',
                            'altFormat' => 'yy-mm-dd', // show to user format
                            'changeYear' => true,
                        ),
                        'htmlOptions' => array(
                            'style' => 'padding:3px 4px;',
                            'size' => 10,
                        ),
                    ));
                    ?>
                </td>
                <td width="10" class="no-border">s.d.</td>
                <td width="100" class="no-border"><?php
                    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'value'=>$date_end,
                        'name' => 'date_end',
                        'options' => array(
                            'showAnim' => 'fold',
                            'dateFormat' => 'yy-mm-dd', // save to db format
                            'altField' => '#self_pointing_id',
                            'altFormat' => 'yy-mm-dd', // show to user format
                            'changeYear' => true,
                        ),
                        'htmlOptions' => array(
                            'style' => 'padding:3px 4px;',
                            'size' => 10,
                        ),
                    ));
                    ?></td>
                <td class="no-border"><input type="submit" name="search" class="button" value="Tampilkan" /></td>
            </tr>
        </table>
    </form>
</div>
<br />
<div class="list">
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th rowspan="2">Tanggal</th>
            <th rowspan="2">Keterangan</th>
            <th colspan="2">Nominal</th>
        </tr>
        <tr>
            <th>Masuk</th>
            <th>Keluar</th>
        </tr>
        <?
        if ($model) {
            $saldo = 0;
            $totalmasuk = 0;
            $totalkeluar = 0;
            foreach ($model as $row) {
                $saldo = ($row->ewallet_log_status == "credit") ? ($saldo + $row->ewallet_log_value) : ($saldo - $row->ewallet_log_value);

                $masuk = ($row->ewallet_log_status == "credit") ? $row->ewallet_log_value : 0;
                $keluar = ($row->ewallet_log_status == "debit") ? $row->ewallet_log_value : 0;
                ?>
                <tr>
                    <td align="center"><?php echo $row->ewallet_log_datetime; ?></td>
                    <td align="left"><?php echo $row->ewallet_log_note; ?></td>
                    <td align="right"><?php echo number_format($masuk); ?></td>
                    <td align="right"><?php echo number_format($keluar); ?></td>
                </tr>
                <?
                $totalmasuk += $masuk;
                $totalkeluar += $keluar;
            }
            ?>
            <tr>
                <td colspan="2" align="center"><b>T O T A L</b></td>
                <td align="right"><b><?php echo number_format($totalmasuk); ?></b></td>
                <td align="right"><b><?php echo number_format($totalkeluar); ?></b></td>
            </tr>
            <?
        } else {
            ?>
            <tr>
                <td align="center" colspan="5"><b>DATA KOSONG</b></td>
            </tr>
            <?
        }
        ?>
    </table>
</div>